/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.javanile.chess.stone;

import java.io.*;

/**
 *
 * @author totalinnovation
 */
public class Session {
    private long start;
    private String sfile;
    public Session() {
	start = System.currentTimeMillis();
	//sfile = "session/"+start+".html";
	try {	    
	    if ((new File("session")).mkdir()) {
	    }   
	} catch(Exception e) {}
	sfile = "session/motorino.html";
	resetfile();
	append("<style>body{font-family:monospace;}</style>");
    }
    public void append(String m) {
	try {
	BufferedWriter out = new BufferedWriter(new FileWriter(sfile, true));
	out.write("<div>"+m+"</div>");
	out.close();
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
    public void resetfile() {
	try {
	BufferedWriter out = new BufferedWriter(new FileWriter(sfile, false));
	out.write("<div>[start]</div>");
	out.close();
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
    public String inputfile() {
	try {
	    FileReader fi = new FileReader("session/input.txt");
	    BufferedReader in   = new BufferedReader(fi);
	    String s = null;
	    String o = "";
            while ((s = in.readLine()) != null) {
		o+=s+"\n";
            }
	    return o;
	} catch (Exception e) {
	    //e.printStackTrace();
	}
	return "";
    }
}
